package com.oracle.sbdb.bo;

import java.util.HashMap;
import java.util.Map;

import com.oracle.sbdb.dao.ComponentDao;
import com.oracle.sbdb.model.Component;

public class ComponentBo {
	public static ComponentBo INSTANCE = new ComponentBo();

	private static ComponentDao componentDao = new ComponentDao();

	private static Map<Integer, Component> componentMap = new HashMap<Integer, Component>();

	private ComponentBo() {
	};

	public String getComponentNamebyID(int componentId) {
		String res = null;
		
		if (componentMap.containsKey(componentId)) {
			res = componentMap.get(componentId).getComponent_name();
		} else {
			Component component = componentDao.selectbyId(componentId);
			if (component != null) {
				componentMap.put(componentId, component);
				res = component.getComponent_name();
			}
		}
		
		return res;
	}
}
